#ifndef   FOLLOWER_H
#define   FOLLOWER_H

#include "utils/mutex.h"
#include "utils/condition.h"
#include "utils/thread_utils.h"
#include <stdio.h>
namespace vpm
{
	namespace utils
	{
		class Follower
		{
		public:
			Follower(Mutex & mutex):m_mutex(mutex)
			{
				m_thrdOwner = thread_id();
			}
			// 	~Follower()
			// 	{
			// 		printf("destruct follower :%p \n", this); 
			// 	}

			void wait (void)
			{
				this->m_followerCondition.wait (m_mutex);
			}

			void signal (void)
			{
				this->m_followerCondition.signal();
			}

			ThreadId owner (void) const 
			{
				return this->m_thrdOwner;
			}

		private:
			Condition m_followerCondition;
			ThreadId m_thrdOwner;
			Mutex& m_mutex; 
		};
	}
}
#endif // 
